﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.UsageInfo", ValueObject=true, ServerTypeId="{7ec28504-35f9-4fcf-a09f-401024417292}")]
    public sealed class UsageInfo : ClientValueObject
    {
        private long m_bandwidth;
        private long m_discussionStorage;
        private long m_hits;
        private long m_storage;
        private double m_storagePercentageUsed;
        private long m_visits;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            string str = peekedName;
            if (str != null)
            {
                if (!(str == "Storage"))
                {
                    if (str == "StoragePercentageUsed")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_storagePercentageUsed = reader.ReadDouble();
                        return flag;
                    }
                    if (str == "Bandwidth")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_bandwidth = reader.ReadInt64();
                        return flag;
                    }
                    if (str == "Visits")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_visits = reader.ReadInt64();
                        return flag;
                    }
                    if (str == "Hits")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_hits = reader.ReadInt64();
                        return flag;
                    }
                    if (str == "DiscussionStorage")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_discussionStorage = reader.ReadInt64();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.m_storage = reader.ReadInt64();
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Storage");
            DataConvert.WriteValueToXmlElement(writer, this.Storage, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "StoragePercentageUsed");
            DataConvert.WriteValueToXmlElement(writer, this.StoragePercentageUsed, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Bandwidth");
            DataConvert.WriteValueToXmlElement(writer, this.Bandwidth, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Visits");
            DataConvert.WriteValueToXmlElement(writer, this.Visits, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Hits");
            DataConvert.WriteValueToXmlElement(writer, this.Hits, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "DiscussionStorage");
            DataConvert.WriteValueToXmlElement(writer, this.DiscussionStorage, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public long Bandwidth
        {
            get
            {
                return this.m_bandwidth;
            }
        }

        [Remote]
        public long DiscussionStorage
        {
            get
            {
                return this.m_discussionStorage;
            }
        }

        [Remote]
        public long Hits
        {
            get
            {
                return this.m_hits;
            }
        }

        [Remote]
        public long Storage
        {
            get
            {
                return this.m_storage;
            }
        }

        [Remote]
        public double StoragePercentageUsed
        {
            get
            {
                return this.m_storagePercentageUsed;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{7ec28504-35f9-4fcf-a09f-401024417292}";
            }
        }

        [Remote]
        public long Visits
        {
            get
            {
                return this.m_visits;
            }
        }
    }
}

